package com.mflex.WHSmartWhouseAd.adapter;

import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mflex.WHSmartWhouseAd.R;
import com.mflex.WHSmartWhouseAd.model.MaterialTaskModel;
import com.mflex.WHSmartWhouseAd.model.TaskForSMTModel;

import java.util.List;

public class MaterialOutStockAdapter extends BaseAdapter {
    List<MaterialTaskModel> items;
    Activity context;

    public MaterialOutStockAdapter(Activity context, List<MaterialTaskModel> items) {
        this.context = context;
        this.items = items;
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MaterialTaskModel item = items.get(position);
        View view = convertView;
        view = context.getLayoutInflater().inflate(R.layout.item_material_outstock_list, null);
        ((TextView) view.findViewById(R.id.txtTask)).setText(item.getTaskNo());
        ((TextView) view.findViewById(R.id.txtFloor)).setText(item.getOriginalArea());
        ((TextView) view.findViewById(R.id.txtMaterialType)).setText(item.getMaterialClass());
        ((TextView) view.findViewById(R.id.txtStatus)).setText(item.getTaskStatus());

        if (position % 2 == 0) {
            ((LinearLayout) view.findViewById(R.id.txtList)).setBackgroundColor(Color.rgb(221, 221, 221));
        }

        return view;
    }
}